package com.jhgsys.internal.system.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jhgsys.internal.common.annotation.IsMobile;
import com.jhgsys.internal.common.converter.TimeConverter;
import com.wuwenze.poi.annotation.Excel;
import com.wuwenze.poi.annotation.ExcelField;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;

/**
 * @author MrBird
 */
@Data
@TableName("BASIC_USER")
@Excel("用户信息表")
public class User implements Serializable {

    private static final long serialVersionUID = -4352868070794165001L;
    // 用户状态：有效
    public static final String STATUS_VALID = "1";
    // 用户状态：锁定
    public static final String STATUS_LOCK = "0";
    // 默认头像
    public static final String DEFAULT_AVATAR = "default.jpg";
    // 默认密码
    public static final String DEFAULT_PASSWORD = "123456";
    // 性别男
    public static final String SEX_MALE = "1";
    // 性别女
    public static final String SEX_FEMALE = "2";
    // 性别保密
    public static final String SEX_UNKNOW = "0";
    // 黑色主题
    public static final String THEME_BLACK = "black";
    // 白色主题
    public static final String THEME_WHITE = "white";
    // TAB开启
    public static final String TAB_OPEN = "1";
    // TAB关闭
    public static final String TAB_CLOSE = "0";


    /**
     * 用户 ID
     */
    @TableId(value = "USER_ID", type = IdType.ASSIGN_UUID)
    private String userId;

    /**
     * 用户名
     */
    @TableField("USER_NAME")
    @ExcelField(value = "用户名")
    private String userName;

    /**
     * 租户 ID
     */
    @TableField(value = "TENANT_ID")
    private String tenantId;


    /**
     * 密码
     */
    @TableField("PASSWORD")
    private String password;

    /**
     * 姓名
     */
    @TableField("UNAME")
    @ExcelField(value = "姓名")
    private String uname;

    /**
     * 部门 ID
     */
    @TableField("DEPT_ID")
    private String deptId;

    /**
     * 用户工号
     */
    @TableField("user_no")
    private String userNo;

    /**
     * 身份证号
     */
    @TableField("identification_no")
    private String identificationNo;

    /**
     * 是否部门负责人 0：否 1：是
     */
    @TableField("DEPT_LEADER_FLG")
    @ExcelField(value = "是否部门负责人", writeConverterExp = "0=否,1=是")
    private String deptLeaderFlg;

    /**
     * 用户类别 1：本工 2：外包工 3：外协工
     */
    @TableField("USER_TYPE")
    @ExcelField(value = "用户类别", writeConverterExp = "1=本工,2=外包工,3=外协工")
    private String userType;

    /**
     * 承包商ID
     */
    @TableField("contractor_id")
    private String contractorId;

    /**
     * 承包队ID
     */
    @TableField("contractor_team_id")
    private String contractorTeamId;

    /**
     * 邮箱
     */
    @TableField("EMAIL")
    @Size(max = 50, message = "{noMoreThan}")
    @Email(message = "{email}")
    @ExcelField(value = "邮箱")
    private String email;

    /**
     * 联系电话
     */
    @TableField("MOBILE")
    @IsMobile(message = "{mobile}")
    @ExcelField(value = "联系电话")
    private String mobile;


    @TableField("TELEPHONE")
    private String telephone;

    /**
     * 性别 0男 1女 2 保密
     */
    @TableField("SSEX")
    @NotBlank(message = "{required}")
    @ExcelField(value = "性别", writeConverterExp = "0=保密,1=男,2=女")
    private String sex;

    /**
     * 头像
     */
    @TableField("AVATAR")
    private String avatar;

    /**
     * 主题
     */
    @TableField("THEME")
    private String theme;

    /**
     * 是否开启 tab 0开启，1关闭
     */
    @TableField("IS_TAB")
    private String isTab;

    /**
     * 描述
     */
    @TableField("DESCRIPTION")
    @Size(max = 100, message = "{noMoreThan}")
    @ExcelField(value = "个人描述")
    private String description;

    /**
     * 岗位ID
     */
    @TableField("POST_ID")
    private String postId;

    /**
     * 入职时间
     */
    @TableField("JOIN_DATE")
    @ExcelField(value = "入职时间", writeConverter = TimeConverter.class)
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date joinDate;

    /**
     * 工龄
     */
    @TableField("SENIORITY")
    private Integer seniority;

    /**
     * 文化水平
     */
    @TableField("LITERACY")
    private String literacy;

    /**
     * 用户积分
     */
    @TableField("TOTAL_SCORE")
    private Integer totalScore;

    /**
     * 最近访问时间
     */
    @TableField("LAST_LOGIN_TIME")
    @ExcelField(value = "最近访问时间", writeConverter = TimeConverter.class)
    @JsonFormat(pattern = "yyyy年MM月dd日 HH时mm分ss秒", timezone = "GMT+8")
    private Date lastLoginTime;


    /**
     * 状态 0锁定 1有效
     */
    @TableField("STATUS")
    @ExcelField(value = "状态", writeConverterExp = "0=禁用,1=启用")
    private String status;
    /**
     * 创建人id
     */
    @TableField("CREATED_BY")
    private String createdBy;
    /**
     * 创建时间
     */
    @TableField("CREATED_TIME")
    @ExcelField(value = "创建时间", writeConverter = TimeConverter.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    /**
     * 更新人id
     */
    @TableField("UPDATED_BY")
    private String updatedBy;

    /**
     * 修改时间
     */
    @TableField("UPDATED_TIME")
    @ExcelField(value = "修改时间", writeConverter = TimeConverter.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date modifyTime;
    /**
     * 删除人id
     */
    @TableField("DELETED_BY")
    private String deletedBy;
    /**
     * 删除时间
     */
    @TableField("DELETED_TIME")
    @ExcelField(value = "删除时间", writeConverter = TimeConverter.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date deletedTime;
    /**
     * 删除标记
     */
    @TableField("DELETED_FLG")
    private String deletedFlg;

    /**
     * 部门名称
     */
    @ExcelField(value = "部门")
    @TableField(exist = false)
    private String deptName;

    @TableField("SIGN")
    private String sign;
    /**
     * 角色 ID
     */
    @NotBlank(message = "{required}")
    @TableField(exist = false)
    private String roleId;

    @TableField(exist = false)
    private String postName;

    @TableField(exist = false)
    private String roleName;

    @TableField(exist = false)
    private String contractorName;

    @TableField(exist = false)
    private String teamName;
    /**
     * 部门id集合
     */
    @TableField(exist = false)
    private String deptIds;

    @TableField(exist = false)
    private String createTimeFrom;

    @TableField(exist = false)
    private String createTimeTo;

    @TableField(exist = false)
    private String tenantName;
}
